package com.liveinstars.im.endpoint;

import com.liveinstars.api.im.TodoApi;
import com.liveinstars.api.im.vo.TodoVO;
import com.liveinstars.im.api.IMUserService;
import com.liveinstars.im.common.exception.IMException;
import com.onepiece.shipelves.common.Result;
import com.onepiece.shipelves.common.enums.SystemExceptionEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: ting
 * @date: 2020/4/13
 */
@RestController
public class TodoEndpoint implements TodoApi {

    @Autowired
    @Qualifier("IMUserApiServiceApiImpl")
    IMUserService imUserService;


    @Override
    public Result<List<TodoVO>> listAll() {
        return null;
    }

    @Override
    public List<TodoVO> listActivityTodo(@RequestParam("user_id") Long userId, @RequestParam("type") Integer type) {
        return imUserService.getActivityTodoList(userId, type);
    }

    @Override
    public Result<TodoVO> addTodoResult(@RequestParam("from_user_id") Long fromUserId, @RequestParam("to_user_id") Long toUserId,
                   @RequestParam("type") int type,
                   @RequestParam("activity_id") Integer activityId, @RequestParam("group_id") Long groupId, @RequestParam("req_msg") String reqMsg) {
        Result<TodoVO> result = new Result<>();
        TodoVO todoVO = imUserService.addTodo(fromUserId, toUserId, type, activityId, groupId, reqMsg);
        result.setData(todoVO);
        return result;
    }

    @Override
    public TodoVO addTodo(@RequestParam("from_user_id") Long fromUserId, @RequestParam("to_user_id") Long toUserId,
                   @RequestParam("type") int type,
                   @RequestParam("activity_id") Integer activityId, @RequestParam("group_id") Long groupId, @RequestParam("req_msg") String reqMsg) {
        return imUserService.addTodo(fromUserId, toUserId, type, activityId, groupId, reqMsg);
    }

    @Override
    public Boolean hasJoinTodo(@RequestParam("user_id") Long userId, @RequestParam("id") Integer id) {
        Boolean hasJoinTodo = imUserService.containTodo(userId, id);
        return hasJoinTodo;
    }
}
